home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-05-21 | 2.5 KB | 117 lines | [TEXT/PJMM] |
- unit ListMan;
-
- interface
-
- uses
- Globals, Types, Utilities, Fonts;
-
- procedure CreateListMan (var lh: listHandle; var rView: rect; proc: integer; wp: windowPtr);
- procedure DestroyListMan (var lh: listHandle);
- procedure UpdateListMan (lh: listHandle);
- procedure AddListMan (lh: listHandle; s: str255);
- function GetListManLength (lh: listHandle): integer;
- function HasSelection (lh: listHandle): boolean;
- procedure SetSelectList (lh: listHandle; sel: boolean);
- procedure SetProcID (id: integer; p: procPtr);
-
- implementation
-
- procedure CreateListMan (var lh: listHandle; var rView: rect; proc: integer; wp: windowPtr);
- var
- nrows: integer;
- dataBounds: rect;
- cSize: point;
- begin
- GetListFontInfo(rView, nrows);
- SetRect(dataBounds, 0, 0, 1, 0);
- SetPt(cSize, 0, 0);
- lh := LNew(rView, dataBounds, cSize, proc, wp, true, false, false, true);
- end;
-
- procedure DestroyListMan (var lh: listHandle);
- begin
- LDispose(lh);
- lh := nil;
- end;
-
- procedure UpdateListMan (lh: listHandle);
- var
- r: rect;
- begin
- r := lh^^.rView;
- EraseRect(r);
- InsetRect(r, -1, -1);
- FrameRect(r);
- LUpdate(lh^^.port^.visRgn, lh);
- ValidRect(r);
- end;
-
- procedure AddListMan (lh: listHandle; s: str255);
- var
- r: integer;
- pt: point;
- width: integer;
- begin
- with lh^^, rView do
- width := right - left - 2 * indent.h;
- DotDotDot(s, width);
- r := LAddRow(1, $7FFF, lh);
- pt.h := 0;
- pt.v := r;
- LSetCell(ptr(longInt(@s) + 1), length(s), pt, lh);
- end;
-
- function GetListManLength (lh: listHandle): integer;
- begin
- GetListManLength := lh^^.dataBounds.bottom;
- end;
-
- function HasSelection (lh: listHandle): boolean;
- var
- pt: point;
- begin
- pt.h := 0;
- pt.v := 0;
- HasSelection := LGetSelect(true, pt, lh);
- end;
-
- procedure SetSelectList (lh: listHandle; sel: boolean);
- var
- r: integer;
- pt: point;
- begin
- pt.h := 0;
- for r := 0 to lh^^.dataBounds.bottom do begin
- pt.v := r;
- LSetSelect(sel, pt, lh);
- end;
- end;
-
- procedure SetProcID (id: integer; p: procPtr);
- type
- jmpRec = record
- jmp: integer;
- address: procPtr;
- end;
- jmpPtr = ^jmpRec;
- jmpHandle = ^jmpPtr;
- var
- jmph: jmpHandle;
- begin
- jmph := jmpHandle(GetResource('LDEF', id));
- if jmph = nil then begin
- jmph := jmpHandle(NewHandle(sizeof(jmpRec)));
- AddResource(handle(jmph), 'LDEF', id, 'MadeUp LDEF');
- end;
- if GetHandleSize(handle(jmph)) <> sizeof(jmpRec) then begin
- SysBeep(1);
- Debugger;
- ExitToShell;
- end;
- HLock(handle(jmph));
- HNoPurge(handle(jmph));
- jmph^^.jmp := $4EF9;
- jmph^^.address := p;
- end;
-
- end.